/**
 *  ||==\\ ==|| \\===
 *  ||  || ==||  \==/
 *  ||==// ==|| ===// (www.d3s.net)
 * 
 * Tween is a part of the D3S Papervision3D Importer Library
 * Please feel free to use, modify, and distribute as long as 
 * as credit is given to the original creator me, Philippe Ajoux.
 * If you have any comments, suggests, requests, or found a bug
 * please send me an e-mail and let me know. You will help everyone.
 * 
 * -----[1] 05.01.07 --------------
 * Original release
 * 
 * @version 05.01.07
 * @author Philippe Ajoux (philippe.ajoux@gmail.com)
 */
package d3s.net.interpolate
{
	/**
	 * Tween is an interpolator that will interpolate any object that
	 * has the three public properties: x, y, z. 
	 * <p>
	 * Tween is an [abstract] class and should never been created as 
	 * it's own instance. Use one of it's subclasses such as LinearTween
	 * or BSplineTween.
	 * <p>
	 * How to use Tween
	 * ---------------------------------------------------------------
	 * //...
	 * //...
	 * tween = new BSplineTween(camera);
	 *	tween.tween([new Number3D(0, 500, -500),
	 *				 new Number3D(-500, 0, 0),
	 *				 new Number3D(0, -500, 500),
	 *				 new Number3D(500, 0, 0),
	 *	 			 new Number3D(0, 500, -500),
	 * 				 new Number3D(-500, 0, -100),
	 *	 			 new Number3D(200, -500, -200),
	 *		 		 new Number3D(0, 500, -500)],
	 *			 	 15);
	 * //...
	 * //...
	 * public function enterFrame(event:Event):void 
	 * {
	 * 		ctime = getTimer();
	 *		tween.update(ctime - otime);
	 *		otime = ctime;
	 * }
	 */
	public class Tween
	{
		protected var points:Array;
		protected var index:int = 0;
		protected var interp:Number = 0;
		
		public var fps:Number;
		public var object:*;
		
		public function Tween(object:*, fps:int = 10)
		{
			this.object = object;
			this.fps = fps;
		}
		
		public function tween(points:Array, time:Number = 1):void 
		{
			index = interp = 0;
			this.points = points;
			fps = points.length / time;
		}
		
		public function update(delta:uint):void 
		{
			interp += fps * delta / 1000;
			if (interp >= 1)
			{
				index++;
				interp = 0;
			}			
		}
	}
}